﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FG_Admin_BLL;
using Model;


namespace FG_Skiing_UI.Areas.FG_Background_UI.Controllers
{
    public class AdminController : Controller
    {
        public int PIndex = 1;
        public int PSize = 5;
        //
        // GET: /FG_Background_UI/Admin/
        /// <summary>
        
        /// 主界面
        /// </summary>
        /// <returns></returns>
        #region
        public ActionResult Index(int ID)
        {
            ViewBag.RID = ID;
            return View();
        }
      
        public JsonResult IndexReady(int RID)
        {
            AdminsBLL bll = new AdminsBLL();
            List<Admins_Power> list = bll.GetPower(RID);
            return Json(list);
        }
        #endregion
        /// <summary>
        /// 前台用户管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Disabled()
        {
            return View();
        }
        /// <summary>
        /// 教学视频
        /// </summary>
        /// <returns></returns>
        public ActionResult videoQuery()
        {
            return View();
        }
        /// <summary>
        /// 炫酷视频
        /// </summary>
        /// <returns></returns>
        public ActionResult videosAdd()
        {
            return View();
        }
        /// <summary>
        /// 票价调整
        /// </summary>
        /// <returns></returns>
        public ActionResult documentQuery()
        {
            return View();
        }
        /// <summary>
        /// 订单管理
        /// </summary>
        /// <returns></returns>
        public ActionResult userdocumentQuery()
        {
            return View();
        }
        /// <summary>
        /// 退票管理
        /// </summary>
        /// <returns></returns>
        public ActionResult usernodocumentQuery()
        {
            return View();
        }
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <returns></returns>
        public ActionResult studentQuery()
        {
            return View();
        }
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <returns></returns>
        public ActionResult teacherQuery()
        {
            AdminsBLL bll = new AdminsBLL();
            return View(bll.GetAdmins(PIndex,PSize));
        }
        /// <summary>
        /// 用户授权
        /// </summary>
        /// <returns></returns>
        public ActionResult authorize()
        {
            return View();
        }
        /// <summary>
        /// 用户禁用
        /// </summary>
        /// <returns></returns>
        public ActionResult Disa()
        {
            return View();
        }
        /// <summary>
        /// 评价删除
        /// </summary>
        /// <returns></returns>
        public ActionResult deletecomment()
        {
            return View();
        }
        /// <summary>
        /// 用户禁言
        /// </summary>
        /// <returns></returns>
        public ActionResult useredit()
        {
            return View();
        }
        /// <summary>
        /// 查看公告
        /// </summary>
        /// <returns></returns>
        public ActionResult afficheQuery()
        {
            return View();
        }
        /// <summary>
        /// 添加公告
        /// </summary>
        /// <returns></returns>
        public ActionResult afficheEdit()
        {
            return View();
        }
        /// <summary>
        /// 添加新闻
        /// </summary>
        /// <returns></returns>
        public ActionResult NewsAdd()
        {
            return View();
        }
        public ActionResult NewsAddDo(News ss)
        {
            NewsBLL bll=new NewsBLL ();
            if (bll.AddNews(ss) > 0)
            {
                return Content("<script>alert('添加成功');location.href='/FG_Background_UI/Admin/SearchNews';</script>");
            }
            else
            {
                return Content("<script>alert('添加失败');location.href='/FG_Background_UI/Admin/NewsAdd';</script>");
            }
        }
        /// <summary>
        /// 查看新闻
        /// </summary>
        /// <returns></returns>
        public ActionResult SearchNews()
        {
            NewsBLL bll=new NewsBLL ();
            return View(bll.GetNews(PIndex,PSize));
        }
        public ActionResult SelectNews(string menuname, int NewsType)
        {
            NewsBLL bll=new NewsBLL ();
            return View("SearchNews", bll.GetNews(PIndex, PSize, menuname, NewsType));
        }
        /// <summary>
        /// 退出后台
        /// </summary>
        /// <returns></returns>
        public ActionResult Login()
        {
            return View();
        }
        public ActionResult LogionDo(string UsersName, string UsersPwd)
        {
            AdminsBLL bll=new AdminsBLL ();
            if (bll.LoginDo(UsersName, UsersPwd) == -1)
            {
                return Content("<script>alert('请输入用户名密码');location.href='/FG_Background_UI/Admin/Login';</script>");
            }
            if (bll.LoginDo(UsersName, UsersPwd) == 0)
            {
                return Content("<script>alert('账号或密码有误');location.href='/FG_Background_UI/Admin/Login';</script>");
            }
            else
            {
                return Content("<script>alert('登陆成功');location.href='/FG_Background_UI/Admin/Index/" + bll.LoginDo(UsersName, UsersPwd) + "';</script>");
            }
        }
    }
}
